<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>使用XYZ的方式加载OpenStreetMap</title>
    <link rel="stylesheet" href="../v6.4.3/css/ol.css">
  </head>
  <body>
    <div id="map" style="height: 500px;"></div>

    <script src="../v6.4.3/build/ol.js"></script>
    <script>
      var mapLayer = new ol.layer.Tile({
        source: new ol.source.XYZ({
          // url: 'http://{a-c}.tile.openstreetmap.org/{z}/{x}/{y}.png'  //XYZ方式加载OpenStreetMap
          url: 'http://webst0{1-4}.is.autonavi.com/appmaptile?lang=zh_cn&size=1&scale=1&style=7&x={x}&y={y}&z={z}' //XYZ方式加载高德地图
        })
      })
      console.log(mapLayer)
      var map = new ol.Map({
        target: 'map',
        layers: [
          mapLayer
        ],
        view: new ol.View({
          center: ol.proj.fromLonLat([104.06, 30.67]),
          zoom: 11
        })
      })
    </script>
  </body>
</html>
